<?php
class BaseDbService
{
	protected $dao;
	
	public function __construct($table)
	{
		$this->dao = new BaseDao($table);
	}
	
	public function get($id)
	{
		return $this->dao->get($id);
	}
	
	public function add($data)
	{
		$result = $this->dao->add($data);
		return $result;
	}
	
	public function update($id,$data)
	{
		$result	= $this->dao->update($id, $data);
		return $result;
	}
	
	public function updateRows($condition, $data)
	{
		return $this->dao->updateRows(array('where'=>$condition), $data);
	}
	
	public function del($id)
	{
		$result	= $this->dao->del($id);
		return $result;
	}
	
	public function deleteRows($condition)
	{
		$result = $this->dao->deleteRows(array('where'=>$condition));
		return $result;
	}
	
	public function fetch($condition)
	{
		return $this->dao->fetch(array('where'=>$condition));
	}
	
	public function count($condition)
	{
		return $this->dao->count(array('where'=>$condition));
	}
	
	public function rows($condition,$orderby='',$fields='',$start=0,$num=0)
	{
		return $this->dao->fetchRows(array('where'=>$condition),$orderby,$fields,$start,$num);
	}
	
	public function getList($condition,$orderby,$start,$num,$fields='')
	{
		$result['count'] 		= $this->dao->count(array('where'=>$condition));
		if($result['count']>0)
		{
			$result['rows'] 	= $this->dao->fetchRows(array('where'=>$condition),$orderby,$fields,$start,$num);
		}
		else
		{
			$result['rows'] 	= false;
		}
		
		return $result;
	}
}